import { Injectable } from '@angular/core';
// import { Platform } from 'ionic-angular';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import { REQ_URL } from '../Constants'
import { HttpService } from '../httpService'
// import { AppGlobal } from '../appGlobal'

/*
  Generated class for the UserProvider provider.

  See https://angular.io/guide/dependency-injection for more info on providers
  and Angular DI.
*/
@Injectable()
export class AnalysisProvider {

    constructor(public http: Http,
        public httpService: HttpService) {
        //console.log('Hello UserProvider Provider');
    }

    /**
      * 获取温度信息 EC
      * @param obj 
      */
    getTemperature(obj) {
        return new Promise((resolve, reject) => {
            this.httpService.postBody(REQ_URL.analysis.getTemperature, obj)
                .then(data => {
                    resolve(data);
                }, err => {
                    reject(err);
                });
        });
    }

     /**
      * 获取虫量信息 EC
      * @param obj 
      */
      getBugRate(obj) {
        return new Promise((resolve, reject) => {
            this.httpService.postBody(REQ_URL.analysis.getBugRate, obj)
                .then(data => {
                    resolve(data);
                }, err => {
                    reject(err);
                });
        });
    }

     /**
      * 获取湿度信息 EC
      * @param obj 
      */
      getHumidity(obj) {
        return new Promise((resolve, reject) => {
            this.httpService.postBody(REQ_URL.analysis.getHumidity, obj)
                .then(data => {
                    resolve(data);
                }, err => {
                    reject(err);
                });
        });
    }
}
